<!-- 页面外套 -->
<div class="page-wrapper" id="personnel_contractor">

    <!-- 数据网格 -->
    <div class="datagrid datagrid-striped" id="personnel_contractor_datagrid">

        <!-- 工具条组 -->
        <div class="tool-group">
            <div class="tool-search">
                <div class="im-label">
                    <div class="input-group">
                        <select class="form-control" id="personnel_contractor_tool_keys">
                            <option value="1">姓名</option>
                            <option value="2">工号</option>
                            <option value="3">电话</option>
                        </select>
                        <span class="input-group-addon fix-border fix-padding"></span>
                        <input type="text" class="form-control" id="personnel_contractor_tool_search">
                    </div>
                </div>
                <label><span>状态：  </span><select class="form-control" id="personnel_contractor_tool_select"><!--JS推进--></select></label>
                <label><button class="btn btn-primary" id="personnel_contractor_search_btn"><i class="icon icon-search"></i> 搜索</button></label>
                <div class="clearfix"></div>
            </div>
            <div class="tool-deal">
                <label><button class="btn btn-primary" id="personnel_contractor_add_btn"><i class="icon icon-plus"></i> 添加</button></label>
                <div class="clearfix"></div>
            </div>
        </div>
        <!-- tool-group -->

        <div class="datagrid-container"></div>
        <ul class="pager btn-mini" data-elements="prev,pages,next"></ul>
    </div>
    <!-- datagrid -->

    <!-- 添加盒子 -->
    <div class="modal modal-for-page fade" aria-hidden="false" id="personnel_contractor_add_box">
        <div class="modal-dialog modal-fullscreen">
            <div class="modal-content">
                <div class="modal-header">
                    <button class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">关闭</span></button>
                    <h4 class="modal-title">添加</h4>
                </div>
                <div class="modal-body">
                    <form class="container form-horizontal">
                        <!-- 个人资料 -->
                        <table class="table table-bordered">
                            <thead><tr><th>个人资料</th></tr></thead>
                            <tbody><tr><td>
                                <div class="form-group require">
                                    <label class="col-sm-2" for="personnel_contractor_add_user">姓名</label>
                                    <div class="col-sm-8"><input type="text" class="form-control input-middle" id="personnel_contractor_add_user"></div>
                                </div>
                                <div class="form-group require">
                                    <label class="col-sm-2" for="personnel_contractor_add_acco">工号</label>
                                    <div class="col-sm-8"><input type="text" class="form-control input-middle" id="personnel_contractor_add_acco"></div>
                                </div>
                                <div class="form-group require">
                                    <label class="col-sm-2" for="personnel_contractor_add_tels">电话</label>
                                    <div class="col-sm-8"><input type="text" class="form-control input-middle" id="personnel_contractor_add_tels"></div>
                                </div>
                                <div class="form-group require">
                                    <label class="col-sm-2" for="personnel_contractor_add_addr">地址</label>
                                    <div class="col-sm-8"><input type="text" class="form-control input-middle" id="personnel_contractor_add_addr"></div>
                                </div>
                                <div class="form-group require">
                                    <label class="col-sm-2" for="personnel_contractor_add_type">承包商类型</label>
                                    <div class="col-sm-8"><select id="personnel_contractor_add_type"  class="form-control input-middle"><!-- JS推进 --></select></div>
                                </div>
                                <div class="form-group require">
                                    <label class="col-sm-2" for="personnel_contractor_add_state">工作状态</label>
                                    <div class="col-sm-8"><select id="personnel_contractor_add_state" class="form-control input-middle"><!-- JS推进 --></select></div>
                                </div>
                            </td></tr></tbody>
                        </table>
                        <!-- 账户信息 -->
                        <table class="table table-bordered">
                            <thead><tr><th>账户信息</th></tr></thead>
                            <tbody><tr><td>
                                <div class="form-group require">
                                    <label class="col-sm-2" for="personnel_contractor_add_card_numb">银行卡号</label>
                                    <div class="col-sm-8"><input type="text" class="form-control input-middle" id="personnel_contractor_add_card_numb"></div>
                                </div>
                                <div class="form-group require">
                                    <label class="col-sm-2" for="personnel_contractor_add_card_bank">开户行</label>
                                    <div class="col-sm-8"><input type="text" class="form-control input-middle" id="personnel_contractor_add_card_bank"></div>
                                </div>
                                <div class="form-group require">
                                    <label class="col-sm-2" for="personnel_contractor_add_card_user">开户人</label>
                                    <div class="col-sm-8"><input type="text" class="form-control input-middle" id="personnel_contractor_add_card_user"></div>
                                </div>
                            </td></tr></tbody>
                        </table>
                        <!-- 证件信息 -->
                        <table class="table table-bordered">
                            <thead><tr><th>证件信息 <span class="small text-red">(图片大小不超过1M)</span></th></tr></thead>
                            <tbody><tr><td>
                                <ul>
                                    <li class="col-sm-2">
                                        <!-- 单图上传 -->
                                        <div class="card zui_upload_img" id="personnel_contractor_add_uploader1" path="">
                                            <span class="media-wrapper"><img src=""></span>
                                            <div class="uploader-message text-center"><div class="content"></div></div>
                                            <div class="uploader-files file-list hidden"></div>
                                            <span class="card-heading">身份证正面</span>
                                            <span class="card-actions">
                                                <a class="btn btn-danger  btn-mini uploader-btn-delete">清空</a>
                                                <a class="btn btn-primary btn-mini uploader-btn-browse">上传</a>
                                            </span> 
                                        </div>
                                        <!-- zui_upload_img -->
                                    </li>
                                    <li class="col-sm-2">
                                        <!-- 单图上传 -->
                                        <div class="card zui_upload_img" id="personnel_contractor_add_uploader2" path="">
                                            <span class="media-wrapper"><img src=""></span>
                                            <div class="uploader-message text-center"><div class="content"></div></div>
                                            <div class="uploader-files file-list hidden"></div>
                                            <span class="card-heading">身份证反面</span>
                                            <span class="card-actions">
                                                <a class="btn btn-danger  btn-mini uploader-btn-delete">清空</a>
                                                <a class="btn btn-primary btn-mini uploader-btn-browse">上传</a>
                                            </span> 
                                        </div>
                                        <!-- zui_upload_img -->
                                    </li>
                                </ul>
                            </td></tr><tr><td>
                                        <!-- 组队上传 -->
                                        <div class="uploader" id="personnel_contractor_add_uploaders" path="">
                                            <div class="uploader-message text-center"><div class="content"></div></div>
                                            <div class="uploader-files file-list"></div>
                                            <button type="button" class="btn btn-default uploader-btn-browse">添加其他证件</button>
                                        </div>
                                        <!-- uploader -->
                            </td></tr></tbody>
                        </table>
                        <div class="text-center">
                            <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                            <button type="button" class="btn btn-primary" id="personnel_contractor_add_submit">保存</button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
    <!-- personnel_contractor_add_box -->

    <!-- 查看盒子 -->
    <div class="modal modal-for-page fade" aria-hidden="false" id="personnel_contractor_show_box">
        <div class="modal-dialog modal-fullscreen">
            <div class="modal-content">
                <div class="modal-header">
                    <button class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">关闭</span></button>
                    <h4 class="modal-title">查看</h4>
                </div>
                <div class="modal-body"><!-- JS推进 --></div>
            </div>
        </div>
    </div>
    <!-- personnel_contractor_show_box -->

    <!-- 修改盒子 -->
    <div class="modal modal-for-page fade" aria-hidden="false" id="personnel_contractor_edit_box">
        <div class="modal-dialog modal-fullscreen">
            <div class="modal-content">
                <div class="modal-header">
                    <button class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">关闭</span></button>
                    <h4 class="modal-title">修改</h4>
                </div>
                <div class="modal-body">
                    <form class="container form-horizontal">
                        <!-- 个人资料 -->
                        <table class="table table-bordered">
                            <thead><tr><th>个人资料</th></tr></thead>
                            <tbody><tr><td>
                                <div class="form-group require">
                                    <label class="col-sm-2" for="personnel_contractor_edit_user">姓名</label>
                                    <div class="col-sm-8"><input type="text" class="form-control input-middle" id="personnel_contractor_edit_user"></div>
                                </div>
                                <div class="form-group require">
                                    <label class="col-sm-2" for="personnel_contractor_edit_acco">工号</label>
                                    <div class="col-sm-8"><input type="text" class="form-control input-middle" id="personnel_contractor_edit_acco"></div>
                                </div>
                                <div class="form-group require">
                                    <label class="col-sm-2" for="personnel_contractor_edit_tels">电话</label>
                                    <div class="col-sm-8"><input type="text" class="form-control input-middle" id="personnel_contractor_edit_tels"></div>
                                </div>
                                <div class="form-group require">
                                    <label class="col-sm-2" for="personnel_contractor_edit_addr">地址</label>
                                    <div class="col-sm-8"><input type="text" class="form-control input-middle" id="personnel_contractor_edit_addr"></div>
                                </div>
                                <div class="form-group require">
                                    <label class="col-sm-2" for="personnel_contractor_edit_type">承包商类型</label>
                                    <div class="col-sm-8"><select id="personnel_contractor_edit_type"  class="form-control input-middle"><!-- JS推进 --></select></div>
                                </div>
                                <div class="form-group require">
                                    <label class="col-sm-2" for="personnel_contractor_edit_state">工作状态</label>
                                    <div class="col-sm-8"><select id="personnel_contractor_edit_state" class="form-control input-middle"><!-- JS推进 --></select></div>
                                </div>
                            </td></tr></tbody>
                        </table>
                        <!-- 账户信息 -->
                        <table class="table table-bordered">
                            <thead><tr><th>账户信息</th></tr></thead>
                            <tbody><tr><td>
                                <div class="form-group require">
                                    <label class="col-sm-2" for="personnel_contractor_edit_card_numb">银行卡号</label>
                                    <div class="col-sm-8"><input type="text" class="form-control input-middle" id="personnel_contractor_edit_card_numb"></div>
                                </div>
                                <div class="form-group require">
                                    <label class="col-sm-2" for="personnel_contractor_edit_card_bank">开户行</label>
                                    <div class="col-sm-8"><input type="text" class="form-control input-middle" id="personnel_contractor_edit_card_bank"></div>
                                </div>
                                <div class="form-group require">
                                    <label class="col-sm-2" for="personnel_contractor_edit_card_user">开户人</label>
                                    <div class="col-sm-8"><input type="text" class="form-control input-middle" id="personnel_contractor_edit_card_user"></div>
                                </div>
                            </td></tr></tbody>
                        </table>
                        <!-- 证件信息 -->
                        <table class="table table-bordered">
                            <thead><tr><th>证件信息 <span class="small text-red">(图片大小不超过1M)</span></th></tr></thead>
                            <tbody><tr><td>
                                <ul>
                                    <li class="col-sm-2">
                                        <!-- 单图上传 -->
                                        <div class="card zui_upload_img" id="personnel_contractor_edit_uploader1" path="">
                                            <span class="media-wrapper"><img src=""></span>
                                            <div class="uploader-message text-center"><div class="content"></div></div>
                                            <div class="uploader-files file-list hidden"></div>
                                            <span class="card-heading">身份证正面</span>
                                            <span class="card-actions">
                                                <a class="btn btn-danger  btn-mini uploader-btn-delete">清空</a>
                                                <a class="btn btn-primary btn-mini uploader-btn-browse">上传</a>
                                            </span> 
                                        </div>
                                        <!-- zui_upload_img -->
                                    </li>
                                    <li class="col-sm-2">
                                        <!-- 单图上传 -->
                                        <div class="card zui_upload_img" id="personnel_contractor_edit_uploader2" path="">
                                            <span class="media-wrapper"><img src=""></span>
                                            <div class="uploader-message text-center"><div class="content"></div></div>
                                            <div class="uploader-files file-list hidden"></div>
                                            <span class="card-heading">身份证反面</span>
                                            <span class="card-actions">
                                                <a class="btn btn-danger  btn-mini uploader-btn-delete">清空</a>
                                                <a class="btn btn-primary btn-mini uploader-btn-browse">上传</a>
                                            </span> 
                                        </div>
                                        <!-- zui_upload_img -->
                                    </li>
                                </ul>
                            </td></tr><tr><td>
                                        <!-- 组队上传 -->
                                        <div class="uploader" id="personnel_contractor_edit_uploaders" path="">
                                            <div class="uploader-message text-center"><div class="content"></div></div>
                                            <div class="uploader-files file-list"></div>
                                            <button type="button" class="btn btn-default uploader-btn-browse">添加其他证件</button>
                                        </div>
                                        <!-- uploader -->
                            </td></tr></tbody>
                        </table>
                        <div class="text-center">
                            <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                            <button type="button" class="btn btn-primary" id="personnel_contractor_edit_submit">保存</button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
    <!-- personnel_contractor_edit_box -->

    <!-- 删除盒子 -->
    <div class="modal modal-for-page fade" aria-hidden="false" id="personnel_contractor_dele_box">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">关闭</span></button>
                    <h4 class="modal-title">删除</h4>
                </div>
                <div class="modal-body">
                    <p class="text-danger"><i class="icon icon-warning-sign"></i> 是否删除？</p>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <button type="button" class="btn btn-danger"  id="personnel_contractor_dele_submit">提交</button>
                </div>
            </div>
        </div>
    </div>
    <!-- personnel_contractor_dele_box -->

</div>
<!-- page-wrapper -->

<script>
$(function(){
   
    //变量声明-----------------------------------------------------------------------------------------------
    var 
    personnel_contractor                    = $("#personnel_contractor"),                   //页面ID
    personnel_contractor_datagrid           = $("#personnel_contractor_datagrid"),          //数据表格
    //搜索
    personnel_contractor_tool_keys          = $("#personnel_contractor_tool_keys"),         //搜索类别
    personnel_contractor_tool_search        = $("#personnel_contractor_tool_search"),       //搜索字段
    personnel_contractor_tool_select        = $("#personnel_contractor_tool_select"),       //下拉选择
    personnel_contractor_search_btn         = $("#personnel_contractor_search_btn"),        //搜索按钮
    //添加
    personnel_contractor_add_btn            = $("#personnel_contractor_add_btn"),           //添加按钮
    personnel_contractor_add_box            = $("#personnel_contractor_add_box"),           //添加盒子
    personnel_contractor_add_submit         = $("#personnel_contractor_add_submit"),        //添加提交
    personnel_contractor_add_user           = $("#personnel_contractor_add_user"),          //姓名字段
    personnel_contractor_add_acco           = $("#personnel_contractor_add_acco"),          //工号字段
    personnel_contractor_add_tels           = $("#personnel_contractor_add_tels"),          //手机字段
    personnel_contractor_add_addr           = $("#personnel_contractor_add_addr"),          //地址字段
    personnel_contractor_add_type           = $("#personnel_contractor_add_type"),          //承包商类型
    personnel_contractor_add_state          = $("#personnel_contractor_add_state"),         //工作状态
    personnel_contractor_add_card_numb      = $("#personnel_contractor_add_card_numb"),     //银行卡号
    personnel_contractor_add_card_bank      = $("#personnel_contractor_add_card_bank"),     //开户行
    personnel_contractor_add_card_user      = $("#personnel_contractor_add_card_user"),     //开户人
    personnel_contractor_add_uploader1      = $("#personnel_contractor_add_uploader1"),
    personnel_contractor_add_uploader2      = $("#personnel_contractor_add_uploader2"),
    personnel_contractor_add_uploaders      = $("#personnel_contractor_add_uploaders"),
    //修改
    personnel_contractor_edit_btn           = $("#personnel_contractor_edit_btn"),          //修改按钮
    personnel_contractor_edit_box           = $("#personnel_contractor_edit_box"),          //修改盒子
    personnel_contractor_edit_submit        = $("#personnel_contractor_edit_submit"),       //修改提交
    personnel_contractor_edit_user          = $("#personnel_contractor_edit_user"),         //姓名字段
    personnel_contractor_edit_acco          = $("#personnel_contractor_edit_acco"),         //工号字段
    personnel_contractor_edit_tels          = $("#personnel_contractor_edit_tels"),         //手机字段
    personnel_contractor_edit_addr          = $("#personnel_contractor_edit_addr"),         //地址字段
    personnel_contractor_edit_type          = $("#personnel_contractor_edit_type"),         //承包商类型
    personnel_contractor_edit_state         = $("#personnel_contractor_edit_state"),        //工作状态
    personnel_contractor_edit_card_numb     = $("#personnel_contractor_edit_card_numb"),    //银行卡号
    personnel_contractor_edit_card_bank     = $("#personnel_contractor_edit_card_bank"),    //开户行
    personnel_contractor_edit_card_user     = $("#personnel_contractor_edit_card_user"),    //开户人
    personnel_contractor_edit_uploader1     = $("#personnel_contractor_edit_uploader1"),
    personnel_contractor_edit_uploader2     = $("#personnel_contractor_edit_uploader2"),
    personnel_contractor_edit_uploaders     = $("#personnel_contractor_edit_uploaders"),
    //查看
    personnel_contractor_show_box           = $("#personnel_contractor_show_box"),          //查看盒子
    //删除
    personnel_contractor_dele_box           = $("#personnel_contractor_dele_box"),          //删除盒子
    personnel_contractor_dele_submit        = $("#personnel_contractor_dele_submit");       //删除提交

    //接口对象-----------------------------------------------------------------------------------------------
    if( window.STATE == "local" ){

        //本地接口
        var personnel_contractor_api = {
            datagrid  : LOCAL + "Test/Personnel/contractor.json",                               //数据表格
            select    : LOCAL + "Test/test_select.json",                                        //下拉选择
            uploader  : LOCAL + "Test/test_upload.php",                                         //上传路径
            modal_edit: LOCAL + "Test/Personnel/contractor_edit.json",                          //修改盒子
        }

    } else if ( window.STATE == "route" ){

        //远程接口
        var personnel_contractor_api = {
            datagrid: ROUTE + "Contractor/GetContractor",
            add: ROUTE + "Contractor/addContractor",
            select: ROUTE + "Contractor/GetContractorClass",
            updateDetails: ROUTE + "Contractor/getContractorDetail",
            update: ROUTE + "Contractor/upadteContractor",
        }

    }
 
    //数据表格-----------------------------------------------------------------------------------------------
    personnel_contractor_datagrid.datagrid({
        height      : zui_datagrid_height(personnel_contractor_datagrid),
        sortable    : false,
        cache       : false,
        showRowIndex: true,
        configs     : {
            R0:{className:"text-center"},
            C1:{className:"cell-hidden"}
        },
        states      : {
            fixedLeftUntil  : 3,
            pager           : {
                page        : 1,
                recPerPage  : window.REC_PER_PAGE,
            }
        },
        dataSource : {
            cols   : [
                {name:"id",    label:"ID",                width:49 },
                {name:"user",  label:"姓名",              width:80 },
                {name:"numb",  label:"工号",              width:80 },
                {name:"tels",  label:"电话",              width:100},
                {name:"addr",  label:"地址",              width:180},
                {name:"type",  label:"承包商类型",        width:120},
                {name:"state", label:"工作状态",          width:100},
                {name:"constr",label:"在施工地数",        width:100},
                {name:"money1",label:"在建施工合同总金额",width:150},
                {name:"money2",label:"施工合同总金额",    width:150},
                {name:"money3",label:"巡检奖赏次数/金额", width:150},
                {name:"money4",label:"巡检处罚次数/金额", width:150},
                {name:"period",label:"保期维修率",        width:120},
                {name:"result",label:"操作",              width:150,  //未竣工项目数(未竣工项目数为0显示删除|不为0隐藏删除)
                    html:true,
                    valueOperator : {
                        getter : function(dataValue,cell){
                            var temp = `
                                <a rowIndex="${cell.rowIndex}" class="personnel_contractor_show_btn">查看</a>
                                <a rowIndex="${cell.rowIndex}" class="personnel_contractor_edit_btn">修改</a>
                            `;
                            if( dataValue=="0" ){
                                temp += `<a rowIndex="${cell.rowIndex}" class="personnel_contractor_dele_btn">删除</a>`;
                            }
                            return temp;
                        }
                    }
                }
            ],
            remote : function(){
                return {
                    url     : personnel_contractor_api.datagrid,
                    type    : "POST",
                    dataType: "json",
                }
            }
        }
    });

    //变量声明-----------------------------------------------------------------------------------------------
    var
    personnel_contractor_datagrid_obj   = personnel_contractor_datagrid.data("zui.datagrid"),   //表格对象
    personnel_contractor_show_btn       = ".personnel_contractor_show_btn",                     //查看
    personnel_contractor_edit_btn       = ".personnel_contractor_edit_btn",                     //修改
    personnel_contractor_dele_btn       = ".personnel_contractor_dele_btn";                     //删除
  
    //上传创建-----------------------------------------------------------------------------------------------
    zui_upload_img({upid:"personnel_contractor_add_uploader1"});
    zui_upload_img({upid:"personnel_contractor_add_uploader2"});
    zui_upload_group({upid:"personnel_contractor_add_uploaders",type:"img"});

    //下拉选项-----------------------------------------------------------------------------------------------
    //状态
    $.ajax({
        url     : personnel_contractor_api.select,
        type    : "post",
        dataType: "json",
        data    : {},
        success : function(data){
            if( data.status>0 ){
                var data = data.data;
                var option = "<option value='0'>全部</option>";
                for(var i=0;i<data.length;i++){
                    option += "<option value='"+data[i].id+"'>"+data[i].name+"</option>"
                }
                personnel_contractor_tool_select.html(option);             //工具条
                personnel_contractor_add_state.html(option);                //添加
                personnel_contractor_edit_state.html(option);               //修改
            }            
        }
    });
    //承包商类型
    $.ajax({
        url     : personnel_contractor_api.select,
        type    : "post",
        dataType: "json",
        data    : {},
        success : function(data){
            if( data.status>0 ){
                var data = data.data;
                var option = "<option value='0'>全部</option>";
                for(var i=0;i<data.length;i++){
                    option += "<option value='"+data[i].id+"'>"+data[i].name+"</option>"
                }
                personnel_contractor_add_type.html(option);                 //添加
                personnel_contractor_edit_type.html(option);                //修改
            }
        }
    });

    //搜索按钮-----------------------------------------------------------------------------------------------
    personnel_contractor_search_btn.click(function(){

        //字段整理
        var keyword
        = "?sid="    + personnel_contractor_tool_keys.val()
        + "&search=" + personnel_contractor_tool_search.val() 
        + "&select2="+ personnel_contractor_tool_select.val();

        //GET提交
        zui_datagrid_render(personnel_contractor_datagrid_obj,personnel_contractor_api.datagrid+keyword);

    });

    //添加按钮-----------------------------------------------------------------------------------------------
    personnel_contractor_add_btn.click(function(){
        common_form_reset();
        personnel_contractor_add_box.modal("show");
    });
    //添加提交
    personnel_contractor_add_submit.click(function(){
        $.ajax({
            url     : API.test_response,
            type    : "post",
            dataType: "json",
            data    : {
                user      : personnel_contractor_add_user.val(),
                acco      : personnel_contractor_add_acco.val(),
                tels      : personnel_contractor_add_tels.val(),
                addr      : personnel_contractor_add_addr.val(),
                type      : personnel_contractor_add_type.val(),
                state     : personnel_contractor_add_state.val(),
                card_numb : personnel_contractor_add_card_numb.val(),
                card_bank : personnel_contractor_add_card_bank.val(),
                card_user : personnel_contractor_add_card_user.val(),
                //资料上传
                pic1      : personnel_contractor_add_uploader1.attr("path") || "",
                pic2      : personnel_contractor_add_uploader2.attr("path") || "",
                pics      : personnel_contractor_add_uploaders.attr("path") || "",
            },
            success : function(data){
                if( data.status>0 ){
                    um_tip(data.message);
                    zui_datagrid_reset(personnel_contractor_datagrid_obj,personnel_contractor_api.datagrid);
                } else {
                    um_tip(data.message,"1500","text-danger");
                }
            }
        });
    });
    //添加关闭
    personnel_contractor_add_box.on("hide.zui.modal",function(){
        //上传重置
        zui_upload_reset([
            personnel_contractor_add_uploader1,
            personnel_contractor_add_uploader2,
            personnel_contractor_add_uploaders
        ]);
    });

    //查看按钮-----------------------------------------------------------------------------------------------
    $(document).on("click",personnel_contractor_show_btn,function(){ 

        //数据ID
        var data_id  = zui_datagrid_get_id($(this).attr("rowIndex"));

        //远程提交
        $.ajax({
            url     : personnel_contractor_api.modal_edit,
            type    : "post",
            dataType: "json",
            data    : { id:data_id },
            success : function(data){
                if( data.status>0 ){

                    //查看模板
                    var data = data.data;
                    var temp = `
                        <div class="container">
                            <table class="table table-bordered">
                                <thead><tr><th colspan="2">个人资料</th></tr></thead>
                                <tbody>
                                    <tr><td style="width:120px;">姓名</td><td>${data.user}</td></tr>
                                    <tr><td>工号      </td><td>${data.acco}</td></tr>
                                    <tr><td>手机      </td><td>${data.tel} </td></tr>
                                    <tr><td>地址      </td><td>${data.addr}</td></tr>
                                    <tr><td>承包商类型</td><td>${data.typename}</td></tr>
                                    <tr><td>工作状态  </td><td>${data.statename}</td></tr>
                                </tbody>
                            </table>

                            <table class="table table-bordered">
                                <thead><tr><th colspan="2">账户信息</th></tr></thead>
                                <tbody>
                                    <tr><td style="width:120px;">姓名</td><td>${data.user}</td></tr>
                                    <tr><td>银行卡号  </td><td>${data.card}    </td></tr>
                                    <tr><td>开户行    </td><td>${data.bank}    </td></tr>
                                    <tr><td>开户人    </td><td>${data.carduser}</td></tr>
                                </tbody>
                            </table>

                            <table class="table table-bordered">
                                <thead><tr><th>证件信息</th></tr></thead>
                                <tbody>
                                    <tr><td>
                                        <div class="col-sm-2">
                                            <a class="card zui-upload-img" target="_blank" href="${FILE_PATH}${data.pic1[0].url}">
                                                <span class="media-wrapper"><img src="${FILE_PATH}${data.pic1[0].url}"></span>
                                                <span class="card-heading">身份证正面</span>
                                            </a>
                                        </div>
                                        <div class="col-sm-2">
                                            <a class="card zui-upload-img" target="_blank" href="${FILE_PATH}${data.pic2[0].url}">
                                                <span class="media-wrapper"><img src="${FILE_PATH}${data.pic2[0].url}"></span>
                                                <span class="card-heading">身份证反面</span>
                                            </a>
                                        </div>
                                    </td></tr>
                                    <tr><td>`;
                    for(var i=0;i<data.pics.length;i++){
                        temp += `
                            <div class="col-sm-2">
                                <a class="card zui-upload-img" target="_blank" href="${FILE_PATH}${data.pics[i].url}">
                                    <span class="media-wrapper"><img src="${FILE_PATH}${data.pics[i].url}"></span>
                                    <span class="card-heading">${data.pics[i].name}</span>
                                </a>
                            </div>
                        `;
                    }
                    temp += `</td></tr></tbody></table>
                        <div class="text-center">
                            <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                        </div>
                    </div>`;
                    personnel_contractor_show_box.find(".modal-body").html(temp);                //模板填充
                    personnel_contractor_show_box.modal("show");                                 //盒子显示
                } else {
                    um_tip(data.message,"1500","text-danger");
                }
            }
        });

    });

    //修改按钮-----------------------------------------------------------------------------------------------
    $(document).on("click",personnel_contractor_edit_btn,function(){

        //查看盒子关闭
        personnel_contractor_show_box.modal("hide");

        //数据ID
        var data_id  = zui_datagrid_get_id($(this).attr("rowIndex"));

        //远程提交
        $.ajax({
            url     : personnel_contractor_api.modal_edit,
            type    : "post",
            dataType: "json",
            data    : { id:data_id },
            success : function(data){
                if( data.status>0 ){
                    //数据赋值
                    var data = data.data;
                    //上传创建
                    window.personnel_contractor_edit_uploader1_obj = zui_upload_img({upid:"personnel_contractor_edit_uploader1",list:data.pic1});
                    window.personnel_contractor_edit_uploader2_obj = zui_upload_img({upid:"personnel_contractor_edit_uploader2",list:data.pic2});
                    window.personnel_contractor_edit_uploaders_obj = zui_upload_group({upid:"personnel_contractor_edit_uploaders",type:"img",list:data.pics});
                    //基本信息
                    personnel_contractor_edit_user.val(      data.user     );
                    personnel_contractor_edit_acco.val(      data.acco     );
                    personnel_contractor_edit_tels.val(      data.tel      );
                    personnel_contractor_edit_addr.val(      data.addr     );
                    personnel_contractor_edit_type.val(      data.type     );
                    personnel_contractor_edit_state.val(     data.state    );
                    personnel_contractor_edit_card_numb.val( data.card     );
                    personnel_contractor_edit_card_bank.val( data.bank     );
                    personnel_contractor_edit_card_user.val( data.carduser );
                    //其他操作
                    personnel_contractor_edit_submit.attr("dataId",data_id);                     //数据ID传值
                    personnel_contractor_edit_box.modal("show");                                 //盒子显示
                } else {
                    um_tip(data.message,"1500","text-danger");
                }
            }
        });

    });
    //修改提交
    personnel_contractor_edit_submit.click(function(){

        //数据ID
        var data_id  = $(this).attr("dataId");

        //远程提交
        $.ajax({
            url     : API.test_response,
            type    : "post",
            dataType: "json",
            data    : { 
                id          : data_id,
                user      : personnel_contractor_edit_user.val(),
                acco      : personnel_contractor_edit_acco.val(),
                tels      : personnel_contractor_edit_tels.val(),
                addr      : personnel_contractor_edit_addr.val(),
                type      : personnel_contractor_edit_type.val(),
                state     : personnel_contractor_edit_state.val(),
                card_numb : personnel_contractor_edit_card_numb.val(),
                card_bank : personnel_contractor_edit_card_bank.val(),
                card_user : personnel_contractor_edit_card_user.val(),
                //资料上传
                pic1      : personnel_contractor_edit_uploader1.attr("path") || "",
                pic2      : personnel_contractor_edit_uploader2.attr("path") || "",
                pics      : personnel_contractor_edit_uploaders.attr("path") || "",
            },
            success : function(data){
                if( data.status>0 ){
                    um_tip(data.message);
                    zui_datagrid_reset(personnel_contractor_datagrid_obj,personnel_contractor_api.datagrid);
                } else {
                    um_tip(data.message,"1500","text-danger");
                }
            }
        });

    });
    //修改关闭-销毁
    personnel_contractor_edit_box.on("hide.zui.modal",function(){
        //上传销毁
        zui_upload_destroy([
            personnel_contractor_edit_uploader1_obj,
            personnel_contractor_edit_uploader2_obj,
            personnel_contractor_edit_uploaders_obj
        ]);
    });

    //删除按钮-----------------------------------------------------------------------------------------------
    $(document).on("click",personnel_contractor_dele_btn,function(){

        //数据ID
        var data_id = zui_datagrid_get_id($(this).attr("rowIndex"));

        //其他操作
        personnel_contractor_dele_submit.attr("dataId",data_id);                                //ID传值
        personnel_contractor_dele_box.modal("show");                                            //面板显示

    });
    //删除提交
    personnel_contractor_dele_submit.click(function(){

        //数据ID
        var data_id = $(this).attr("dataId");

        //远程提交
        $.ajax({
            url     : API.test_response,
            type    : "post",
            dataType: "json",
            data    : { id:data_id },
            success : function(data){
                if( data.status>0 ){
                    um_tip(data.message);
                    zui_datagrid_reset(personnel_contractor_datagrid_obj,personnel_contractor_api.datagrid);
                } else {
                    um_tip(data.message,"1500","text-danger");
                }
            }
        });

    });

});//预加载结尾
</script>